package com.fyzk.activity.setting;

import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.TextView;

import com.fyzk.activity.app.App;
import com.fyzk.base.BaseActivity;
import com.fyzk.data.preference.MySharedPreferences;
import com.fyzk.interfaces.onTopTitleClickListener;
import com.fyzk.utils.AppUtil;
import com.fyzk.view.TopTitleView;
import com.tyjc.lottery.R;

import org.xutils.view.annotation.ContentView;
import org.xutils.view.annotation.ViewInject;

/**
 * 
 *	关于页
 */
@ContentView(R.layout.about)
public class AboutActivity extends BaseActivity implements onTopTitleClickListener {

	@ViewInject(R.id.namevsversion)
	private TextView namevsversion;

	@ViewInject(R.id.about_service_qq)
	private TextView serviceQQText;
	
	@ViewInject(R.id.about_top_rl)
	private TopTitleView topView;

	//客服QQ
	private String serviceQQ = "";

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		info();
	}
	
	private void info(){
		topView.setOnTitleClickListener(this);

		try {
			namevsversion.setText("V"+getVersionName());
		} catch (Exception e) {
			e.printStackTrace();
			namevsversion.setText("V1.0.0");
		}

		serviceQQ = MySharedPreferences.getInstance().getServiceQQ();
		String arrayQQ = AppUtil.getFormatStr(
				App.getContext().getResources().getString(R.string.service_qq),
				serviceQQ);

		serviceQQText.setText(arrayQQ);
	}

	/**   
	 * 获取当前程序的版本号    
	 */     
	private String getVersionName() throws Exception{     
	    //获取packagemanager的实例       
	    PackageManager packageManager = this.getPackageManager();     
	    //getPackageName()是你当前类的包名，0代表是获取版本信息      
	    PackageInfo packInfo = packageManager.getPackageInfo(this.getPackageName(), 0);     
	    return packInfo.versionName;      
	}

	@Override
	public void onLeftClick() {
		finish();
	}

	@Override
	public void onCenterClick() {
	}

	@Override
	public void onRightClick() {
	}

	@Override
	public void onRight2Click() {
	}

}
